<?php
class editAction extends rareAction{
	public function execute(){
		$id = $this->getGetParam('id',0);
		if($id==0) redirect('ad/index');
		$dao = new DaoAd();
		$ad = $dao->getOne(" id='$id'");
		$this->assign('ad',$ad);
	}
	public function executePost(){
		$id = $this->getPostParam('id',0);
		if($id==0) jsonReturn(0,'参数错误');
		$ad = $this->getPostParam('ad',array());
		$img = $this->getPostParam('img',array());
		if(!empty($img)){
			$ad['src'] = $img[0];
		}
		if(empty($ad)) jsonReturn(0,'未做修改');
		$dao = new DaoAd();
		$dao->update(" id='$id'",$ad);
		jsonReturn(1,'ok');
	}
}
?>
